﻿@using System.Web.Configuration;
@using System.Security.AccessControl;
@{
    Layout = "~/Views/Shared/_ClearnLayout.cshtml";
    ViewBag.Title = Html.Global("Install_Preparing_Title");
}
<style>
    .d-captable { margin-left: 5px; }
    .d-captable span { vertical-align: top; }
    .d-caption { margin: 5px 0px 0px 0px; color: #314703; font-size: 120%; }
    #suggestion { font-size: 300%; }
    .d-2bad { color: Red; font-weight: bold; }
</style>
@section NavSection
{
    <div style="display: block;">
        <ul id="sequence">
            <li class="d-current"><a href="#"><span>1 </span>@Html.Global("RES_PREPARING")</a></li>
            <li>&gt;</li>
            <li><span>2 </span>@Html.Global("Install_Setup_AdminAccount")</li>
            <li>&gt;</li>
            <li><span>3 </span>@Html.Global("Install_Setup_TopSite")</li>
        </ul>
    </div>
}
<section>
    <header class="d-section">
        <span>@Html.Global("Install_Browser_Capabilities")</span><hr />
    </header>
    <table style="width: 100%">
        <tr>
            <td>
                <div class="d-caption">
                    @Html.Global("Install_Base_Info")</div>
                <table class="d-captable">
                    <tr>
                        <th>
                            @Html.Global("RES_NAME")
                        </th>
                        <td>@Request.Browser.Browser
                        </td>
                        <th>
                            @Html.Global("RES_VERSION"):
                        </th>
                        <td>@Request.Browser.Version
                        </td>
                        <th>
                            EcmaScriptVersion:
                        </th>
                        <td>@Request.Browser.EcmaScriptVersion
                        </td>
                        <td>
                            <img id="supportJSON" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="json"/><span>JSON</span>
                        </td>
                    </tr>
                </table>
                <div class="d-caption">
                    Html5 @Html.Global("RES_FEATURES")</div>
                <table class="d-captable">
                    <tr>
                        <td>
                            <img id="supportCanvas" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="canvas" /><span>canvas</span>
                        </td>
                        <td>
                            <img id="supportLocalStorage" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="localstorage"/><span>local
                                Storage</span>
                        </td>
                        <td>
                            <img id="supportWebStocket" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="webstocket"/><span>web
                                Stocket</span>
                        </td>
                        <td>
                            <img id="supportWebSQL" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="websql"/><span>web
                                Sql</span>
                        </td>
                        <td>
                            <img id="supportGeolocation" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="geolocation"/><span>GEO
                                Location</span>
                        </td>
                </table>
                <div class="d-caption">
                    CSS3 @Html.Global("RES_FEATURES")</div>
                <table class="d-captable">
                    <tr>
                        <td>
                            <img id="supportBoxshadow" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="boxshadow"/><span>Box
                                shadow</span>
                        </td>
                        <td>
                            <img id="supportBorderradius" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="borderradius"/><span>Border
                                Radius</span>
                        </td>
                        <td>
                            <img id="supportBorderimage" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="borderimage"/><span>Border
                                image</span>
                        </td>
                        <td>
                            <img id="supportCssAnimations" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="cssanimations"/><span>Animations</span>
                        </td>
                        <td>
                            <img id="supportCsscolumns" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="csscolumns"/><span>Columns</span>
                        </td>
                        <td>
                            <img id="supportCsstransforms" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="csstransforms"/><span>Transforms</span>
                        </td>
                        <td>
                            <img id="supportCsstransformsd" src="@Url.Content("~/content/images/icon_delete_16.png")" alt="csstransforms3d"/><span>Transforms3D</span>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 250px; vertical-align: top;">
                <div id="suggestion" class="d-2bad">
                    @if (Request.Browser.Browser.Equals("IE", StringComparison.OrdinalIgnoreCase))
                    {
                        <!--[if lt IE 7 ]>@Html.Global("Install_Browser_OutOfDate") <![endif]-->
                        <!--[if IE 7 ]>@Html.Global("Install_Browser_OutOfDate")<![endif]-->
                    }
                </div>
            </td>
        </tr>
    </table>
</section>
<section>
    <header class="d-section">
        <span>@Html.Global("RES_ENCRYPTION")</span><hr />
    </header>
    <div>
        @{ var section = WebConfigurationManager.GetWebApplicationSection("system.web/machineKey") as MachineKeySection;
           if (section.DecryptionKey.Equals("AutoGenerate,IsolateApps") || section.ValidationKey.Equals("AutoGenerate,IsolateApps"))
           {
            <p>
                <img src="@Url.Content("~/content/images/icon_warning_16.png")" style="vertical-align:middle;" />
                @MvcHtmlString.Create(Html.Global("Install_MachineKey_Suggest"))
            </p>
           }
           else
           {
            <p>
                <img src="@Url.Content("~/content/images/icon_accept_16.png")" alt="machinekey"/>
                <span>Pass!</span></p>
           }
        }
    </div>
</section>
<section>
    <header class="d-section">
        <span>@Html.Global("Install_ACL")</span><hr />
    </header>
    <div style="padding: 10px;">
        @{
            var aclPass = true;
            var folders = new string[] { 
                "~/App_GlobalResources/"
                , "~/App_Data/"
                , "~/Content/Themes/"
                , "~/Content/Widgets/"
                , "~/Shared/",
                "~/web.config"
                ,"~/net.config"
                ,"~/health.config"
                ,"~/robots.txt"
            };

            foreach (var folder in folders)
            {
                var path = Server.MapPath(folder);
                if (FileUtility.CheckAccessRight(path, FileSystemRights.Modify))
                {
            <div>
                <img src="@Url.Content("~/content/images/icon_accept_16.png")" alt="acl"/>
                @if (Path.HasExtension(path))
                {
                    <img src="@Url.Content("~/content/images/mime/" + Path.GetExtension(path).Replace(".", "") + ".gif")" alt="acl"/>
                }
                else
                {
                    <img src="@Url.Content("~/content/images/doc_cat.gif")" alt="acl"/>
                }
                <span style="vertical-align: top;">@Url.Content(folder)</span>
            </div>
                }
                else
                {
            <div>
                @{aclPass = false;}
                <img src="@Url.Content("~/content/images/icon_delete_16.png")" alt="acl"/>
                @if (Path.HasExtension(path))
                {
                    <img src="@Url.Content("~/content/images/mime/" + Path.GetExtension(path).Replace(".", "") + ".gif")" alt="acl"/>
                }
                else
                {
                    <img src="@Url.Content("~/content/images/doc_cat.gif")" alt="acl"/>
                }
                <span style="vertical-align: top;">@Url.Content(folder)</span><span style="margin-left: 5px;
                    color: Red;">
                    @Html.Global("Install_Modifed_Permission_Required")</span>
            </div>
                }
            }
        }
    </div>
</section>
<hr />
<ul class="d-horizontal-list" style="padding: 10px; text-align: right;">
    <li>@Ajax.Dna().Link(Html.Global("RES_HELP"), Url.Help(11), Url.Content("~/content/images/help.png")).Options(opts => { opts.Target = "_blank"; }).GetHtml()</li>
    @if (aclPass)
    {
        <li>@Ajax.Dna().Button().LocText("RES_NEXT").ImageIcons(Url.Content("~/content/images/icon_next_16.png")).Click("location=\"" + Url.Action("Account") + "\";").GetHtml()</li>
    }
</ul>
<script type="text/javascript">
    function _setCheckImage(_name,_val) {
        var el = $("#" + _name);
        if (_val) el.attr("src","@Url.Content("~/content/images/icon_accept_16.png")");
        else el.attr("src","@Url.Content("~/content/images/icon_delete_16.png")");
     }
     
     function _suggest(){
     var el=$("#suggestion");
       with (Modernizr)
       {
       //too bad
       el.text("@Html.Global("RES_TOOBAD")!");
       
       if (localstorage && boxshadow && csstransforms && borderradius && JSON)
       {
         el.removeClass("d-2bad");
         el.text("@Html.Global("RES_POOR")");
       }

       if (localstorage && boxshadow && borderimage && cssanimations && csscolumns && csstransforms && borderradius && JSON)
       {
         el.removeClass("d-2bad");
         el.text("@Html.Global("RES_GOOD")!");
       }

       //good
       if (localstorage && boxshadow && borderimage && cssanimations && csscolumns && csstransforms && borderradius && JSON)
       {
         el.removeClass("d-2bad");
         el.text("@Html.Global("RES_GOOD")!");
       }

       //awesome
       if (localstorage && websockets && websqldatabase && geolocation && canvas && boxshadow && borderimage && cssanimations && csscolumns && csstransforms && csstransforms3d && borderradius && JSON)
       {
         el.removeClass("d-2bad");
         el.text("@Html.Global("RES_AWESOME")!");
         }
       }
     }

    $(function () {
       _setCheckImage("supportLocalStorage", Modernizr.localstorage);
       _setCheckImage("supportWebStocket",Modernizr.websockets);
       _setCheckImage("supportWebSQL",Modernizr.websqldatabase);
       _setCheckImage("supportGeolocation",Modernizr.geolocation);
       _setCheckImage("supportCanvas",Modernizr.canvas);
       _setCheckImage("supportBoxshadow",Modernizr.boxshadow);
       _setCheckImage("supportBorderimage",Modernizr.borderimage);
       _setCheckImage("supportCssAnimations",Modernizr.cssanimations);
       _setCheckImage("supportCsscolumns",Modernizr.csscolumns);
       _setCheckImage("supportCsstransforms",Modernizr.csstransforms);
       _setCheckImage("supportCsstransformsd",Modernizr.csstransforms3d);
       _setCheckImage("supportBorderradius",Modernizr.borderradius);
       _setCheckImage("supportJSON",JSON);
       _suggest();
    });
</script>
